﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;

namespace NJL.Web
{
    public partial class Maps : BasePageVisitor
    {
        private readonly BLL.NJL_NEWS bllNews = new BLL.NJL_NEWS();
        private readonly BLL.NJL_PERSON bllPerson = new BLL.NJL_PERSON();
        private readonly BLL.NJL_COMPANY bllCompany = new BLL.NJL_COMPANY();
        private readonly BLL.NJL_USER bllUser = new BLL.NJL_USER();
        private readonly BLL.NJL_ATTRACTION bllAttr = new BLL.NJL_ATTRACTION();
        private readonly BLL.NJL_CS_AREA bllArea = new BLL.NJL_CS_AREA();
        private readonly NJL.BLL.NJL_CUSTOM_AREA bllCustom = new BLL.NJL_CUSTOM_AREA();
        private readonly BLL.NJL_CS_COMPANY_TYPE bllCompanyType = new BLL.NJL_CS_COMPANY_TYPE();
        protected IList<Model.NJL_NEWS> LIST_NEWS;
        protected IList<Model.NJL_USER> LIST_USER_100;
        protected IList<Model.NJL_COMPANY> LIST_COMPANY;
        protected IList<Model.NJL_COMPANY> LIST_COMPANY_1;
        protected IList<Model.NJL_COMPANY> LIST_COMPANY_2;
        protected IList<Model.NJL_ATTRACTION> LIST_ATTRACTION;
        protected string Tel = "";
        protected string ticket = "";
        protected string QQ = "";
        protected string bjch = "";
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                LoadData();
                bind();
            }
            base.LoadPageSeoInformation("地图");
        }
        private void LoadData()
        {
            LIST_NEWS = bllNews.GetModelList(20, "NJL_SYS_BASE_ID='" + WEBSITE_CODE + "' AND IMAGE_CODE is not null AND IMAGE_CODE <> '' ", "CREATE_DATE_TIME desc");
            LIST_USER_100 = bllUser.GetModelList(32, "NJL_SYS_BASE_ID='" + WEBSITE_CODE + "' and TYPE_CODE='2'", "CREATE_DATE_TIME desc");

            LIST_COMPANY_1 = bllCompany.GetModelList(6, "NJL_COMPANY.NJL_SYS_BASE_ID='" + WEBSITE_CODE + "' AND NJL_COMPANY.AUDIT_STATE=1 and NJL_COMPANY.TYPE_CODE='1'", "NJL_COMPANY.VISIT_COUNT DESC");
            LIST_COMPANY_2 = bllCompany.GetModelList(6, "NJL_COMPANY.NJL_SYS_BASE_ID='" + WEBSITE_CODE + "' AND NJL_COMPANY.AUDIT_STATE=1 and NJL_COMPANY.TYPE_CODE='2'", "NJL_COMPANY.VISIT_COUNT DESC");
            LIST_ATTRACTION = bllAttr.GetModelList(6, "NJL_ATTRACTION.NJL_SYS_BASE_ID='" + WEBSITE_CODE + "'", "NJL_ATTRACTION.COMMENT_COUNT DESC");

            LIST_COMPANY = bllCompany.GetModelList(6, "NJL_COMPANY.NJL_SYS_BASE_ID='" + WEBSITE_CODE + "' AND NJL_COMPANY.AUDIT_STATE=1 ", "NJL_COMPANY.CREATE_DATE_TIME DESC");
        }
        void bind()
        {
            DataSet ds;

            if ("" != WEBSITE_FOCUS_CITY_CODE)
            {
                ds = bllCompany.GetList(6, "NJL_COMPANY.NJL_SYS_BASE_ID='" + WEBSITE_CODE + "' and NJL_COMPANY.AUDIT_STATE=1 AND NJL_COMPANY.AREA_CODE='" + WEBSITE_FOCUS_CITY_CODE + "'", "NJL_COMPANY.CREATE_DATE_TIME desc");
            }
            else
            {
                ds = bllCompany.GetList(6, "NJL_COMPANY.NJL_SYS_BASE_ID='" + WEBSITE_CODE + "' and NJL_COMPANY.AUDIT_STATE=1 ", "NJL_COMPANY.CREATE_DATE_TIME desc");
            }
            rptNewsUser.DataSource = ds;
            rptNewsUser.DataBind();


            if ("" != WEBSITE_FOCUS_CITY_CODE)
            {
                ds = bllCompany.GetList(10, "NJL_COMPANY.TYPE_CODE='2' and NJL_COMPANY.NJL_SYS_BASE_ID='" + WEBSITE_CODE + "' and NJL_COMPANY.AUDIT_STATE=1 AND NJL_COMPANY.AREA_CODE='" + WEBSITE_FOCUS_CITY_CODE + "'", "NJL_COMPANY.VISIT_COUNT desc");
            }
            else
            {
                ds = bllCompany.GetList(10, "NJL_COMPANY.TYPE_CODE='2' and NJL_COMPANY.NJL_SYS_BASE_ID='" + WEBSITE_CODE + "' and NJL_COMPANY.AUDIT_STATE=1 ", "NJL_COMPANY.VISIT_COUNT desc");
            }
            rptCompany.DataSource = ds;
            rptCompany.DataBind();

            IList<Model.NJL_CS_AREA> listArea = new BLL.NJL_CS_AREA().GetModelList("deep=2 AND AREA_CODE Like '" + WEBSITE_CODE.Substring(0, 2) + "%'");

            if (WEBSITE_CODE == "110000" || WEBSITE_CODE == "120000" || WEBSITE_CODE == "310000" || WEBSITE_CODE == "500000")
            {
                hidFocusCityCode.Value = WEBSITE_CODE;
            }
            else
            {
                hidFocusCityCode.Value = listArea[0].AREA_CODE;
            }
            ListItem list = new ListItem();
            list.Text =WEBSITE_NAME;
            list.Value = "";
            ddlProvice.Items.Add(list);
            ddlProvice.Enabled=false;
            string ProvinceId = WEBSITE_CODE.Substring(0, 2);
            DataSet dscity = bllArea.GetList("AREA_CODE like '" + ProvinceId + "%00' and deep=2");
            rblType.DataSource = dscity;
            rblType.DataTextField = "AREA_NAME";
            rblType.DataValueField = "AREA_CODE";
            rblType.DataBind();

     

            NJL.BLL.NJL_SYS_CONTACT bllContact = new BLL.NJL_SYS_CONTACT();
            DataSet dsContact = bllContact.GetList("NJL_SYS_BASE_ID='" + WEBSITE_CODE + "' and TYPE_CODE='GGHZ'");
            if (dsContact.Tables[0].Rows.Count > 0)
            {
                Tel = dsContact.Tables[0].Rows[0]["WEBSITE_CONTACT_TEL"].ToString();
                QQ = dsContact.Tables[0].Rows[0]["WEBSITE_CONTACT_QQ"].ToString();
            }
            dsContact = bllContact.GetList("NJL_SYS_BASE_ID='" + WEBSITE_CODE + "' and TYPE_CODE='PWKF'");
            if (dsContact.Tables[0].Rows.Count > 0)
            {
                ticket = dsContact.Tables[0].Rows[0]["WEBSITE_CONTACT_QQ"].ToString();
            }

            dsContact = bllContact.GetList("NJL_SYS_BASE_ID='" + WEBSITE_CODE + "' and TYPE_CODE='BJCH'");
            if (dsContact.Tables[0].Rows.Count > 0)
            {
                bjch = dsContact.Tables[0].Rows[0]["WEBSITE_CONTACT_QQ"].ToString();
            }
        }
    }
}